import { log } from 'console'
import React,{useState} from 'react'

export default function App() {
    const [show, setshow] = useState(true)
  return (
    <div><Navbar title='lzqshii' cb={()=>{
        console.log('dwadawd');
        setshow(!show)
        
    }}></Navbar>
   {show && <Sidebar></Sidebar>}</div>
  )
}
//对属性进行约束
interface IProps{
    title?:string, //?可选
    cb:()=>void
}
function Navbar(props:IProps){
    return (
        <div>
            navbar - <button onClick={()=>{
                props.cb()
            }}>点击切换抽屉</button>
        </div>
    )
}
function Sidebar(){
    return (
        <div>抽屉食物</div>
    )
}